home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
graphics
/
scalemod.frm
< prev
next >
Wrap
Text File
|
1993-05-16
|
11KB
|
333 lines
VERSION 2.00
Begin Form frmScaleMode
Caption = "ScaleMode Display"
ClientHeight = 3885
ClientLeft = 405
ClientTop = 1515
ClientWidth = 4905
Height = 4290
Left = 345
LinkMode = 1 'Source
LinkTopic = "Form1"
ScaleHeight = 3885
ScaleWidth = 4905
Top = 1170
Width = 5025
Begin PictureBox picDraw
DragIcon = SCALEMOD.FRX:0000
Height = 1935
Left = 960
ScaleHeight = 1905
ScaleWidth = 2865
TabIndex = 2
Top = 720
Width = 2895
End
Begin PictureBox picXaxis
Height = 255
Left = 0
ScaleHeight = 225
ScaleWidth = 4665
TabIndex = 1
Top = 3600
Width = 4695
End
Begin PictureBox picYAxis
Height = 3615
Left = 4680
ScaleHeight = 3585
ScaleWidth = 225
TabIndex = 0
Top = 0
Width = 255
End
End
Const DM_COPYPEN = 1
Const DM_NOTXORPEN = 10
Dim oldCursorX As Single
Dim oldCursorY As Single
Dim bTracking As Integer
Dim Anchor(1) As Single
Dim bDrag As Integer
Dim bFirst As Integer
Sub DrawCursorLocation (Source As Control, X As Single, Y As Single, OldRedraw As Integer, NewRedraw As Integer)
Dim fcolor As Long
Dim ii As Integer
Dim sParam As String
Dim oldDrawMode As Integer
Dim oldDrawWidth As Integer
Dim location As Single
If True Then
'Redraw the X-Axis Cursor Marker
oldDrawMode = picXaxis.DrawMode
oldDrawWidth = picXaxis.DrawWidth
picXaxis.DrawMode = DM_NOTXORPEN 'Not XOR
picXaxis.DrawWidth = 2
'Redraw the old mark
If OldRedraw = True Then
location = picXaxis.ScaleWidth * (oldCursorX - Source.ScaleLeft) / Source.ScaleWidth - picXaxis.ScaleLeft
picXaxis.Line (location, 0)-(location, picXaxis.ScaleHeight)
End If
'Draw the new mark
If NewRedraw = True Then
location = picXaxis.ScaleWidth * (X - Source.ScaleLeft) / Source.ScaleWidth + picXaxis.ScaleLeft
picXaxis.Line (location, 0)-(location, picXaxis.ScaleHeight)
End If
'Store the old Cursor locations and reset the Draw Properties
oldCursorX = X
picXaxis.DrawMode = oldDrawMode
picXaxis.DrawWidth = oldDrawWidth
'Redraw the Y-Axis Cursor Marker
oldDrawMode = picXaxis.DrawMode
oldDrawWidth = picXaxis.DrawWidth
'Set DrawMode to NOTXORPEN
picYaxis.DrawMode = DM_NOTXORPEN 'Not XOR
picYaxis.DrawWidth = 2
'Redraw the old mark
If OldRedraw = True Then
location = picYaxis.ScaleHeight * (oldCursorY - Source.ScaleTop) / Source.ScaleHeight - picYaxis.ScaleTop
picYaxis.Line (0, location)-(picYaxis.ScaleWidth, location)
End If
If NewRedraw = True Then
'Draw the new mark
location = picYaxis.ScaleHeight * (Y - Source.ScaleTop) / Source.ScaleHeight + picYaxis.ScaleTop
picYaxis.Line (0, location)-(picYaxis.ScaleWidth, location)
End If
'Store the old Cursor locations and reset the Draw Properties
oldCursorY = Y
picYaxis.DrawMode = oldDrawMode
picYaxis.DrawWidth = oldDrawWidth
Else
ii = SetTextAlign(Source.hDC, TA_BOTTOM)
fcolor = Source.ForeColor
Source.ForeColor = Source.BackColor
Source.CurrentX = oldCursorX
Source.CurrentY = oldCursorY
Source.Print Tag
Source.ForeColor = fcolor
Source.CurrentX = X
Source.CurrentY = Y
oldCursorX = X
oldCursorY = Y
sParam = "(" + LTrim$(RTrim$(Str$(Int(X)))) + "," + LTrim$(RTrim$(Str$(Int(Y)))) + ")"
Source.Print sParam
Source.Tag = sParam
End If
End Sub
Sub DrawXRuler (Source As Control, Ruler As Control)
Const MAJORINC = 10
Const MINORINC = 4
Dim ii As Integer
Dim jj As Integer
Dim numstr As String
Dim ScaleInterval As Single
Dim ScaleValue As Single
Dim MajorInt As Integer
Dim MinorInt As Integer
'Initialize Ruler scale values
picXaxis.ScaleMode = 0 'User-defined
picXaxis.ScaleWidth = 1000
picXaxis.ScaleHeight = 100
MajorInt = Ruler.ScaleWidth / MAJORINC
MinorInt = MajorInt / MINORINC
ScaleValue = Source.ScaleLeft
ScaleInterval = Source.ScaleWidth / MAJORINC
Ruler.Cls
start = Int(Ruler.ScaleLeft)
finish = Int(Ruler.ScaleLeft + Ruler.ScaleWidth)
For ii = start To finish Step MajorInt
numstr = LTrim$(RTrim$(Str$(Int(ScaleValue))))
Ruler.Line (ii, 0)-(ii, Ruler.ScaleHeight / 6)
Ruler.CurrentX = ii - Ruler.TextHeight(numstr) / 2
Ruler.CurrentY = Ruler.ScaleHeight / 6
Ruler.Print numstr
For jj = 1 To MINORINC
Ruler.Line (ii + MinorInt * jj, 0)-(ii + MinorInt * jj, Ruler.ScaleHeight / 8)
Next jj
ScaleValue = ScaleValue + ScaleInterval
Next ii
If bFirst Then
oldDrawMode = picXaxis.DrawMode
oldDrawWidth = picXaxis.DrawWidth
'Set DrawMode to NOTXORPEN
picXaxis.DrawMode = DM_NOTXORPEN 'Not XOR
picXaxis.DrawWidth = 2
location = picXaxis.ScaleWidth * (oldCursorX - ScaleLeft) / ScaleWidth + picXaxis.ScaleLeft
picXaxis.Line (location, 0)-(location, picXaxis.ScaleHeight)
picXaxis.DrawMode = oldDrawMode
picXaxis.DrawWidth = oldDrawWidth
End If
End Sub
Sub DrawYRuler (Source As Control, Ruler As Control)
Const MAJORINC = 10
Const MINORINC = 4
Dim ii As Integer
Dim jj As Integer
Dim numstr As String
Dim ScaleInterval As Single
Dim ScaleValue As Single
Dim MajorInt As Integer
Dim MinorInt As Integer
picYaxis.ScaleMode = 0 'User-defined
picYaxis.ScaleWidth = 100
picYaxis.ScaleHeight = 1000
MajorInt = Ruler.ScaleHeight / MAJORINC
MinorInt = MajorInt / MINORINC
ScaleValue = Source.ScaleTop
ScaleInterval = Source.ScaleHeight / MAJORINC
Ruler.Cls
For ii = Int(Ruler.ScaleTop) To Int(Ruler.ScaleTop + Ruler.ScaleHeight) Step MajorInt
numstr = LTrim$(RTrim$(Str$(Int(ScaleValue))))
Ruler.Line (0, ii)-(Ruler.ScaleWidth / 6, ii)
Ruler.CurrentX = Ruler.ScaleWidth / 6
Ruler.CurrentY = ii - Ruler.TextHeight(numstr) / 2
Ruler.Print numstr
For jj = 1 To MINORINC
Ruler.Line (0, ii + MinorInt * jj)-(Ruler.ScaleWidth / 8, ii + MinorInt * jj)
Next jj
ScaleValue = ScaleValue + ScaleInterval
Next ii
If bFirst Then
oldDrawMode = picXaxis.DrawMode
oldDrawWidth = picXaxis.DrawWidth
'Set DrawMode to NOTXORPEN
picYaxis.DrawMode = 10 'Not XOR
picYaxis.DrawWidth = 2
location = picYaxis.ScaleHeight * (oldCursorY - ScaleTop) / ScaleHeight + picYaxis.ScaleTop
picYaxis.Line (0, location)-(picYaxis.ScaleWidth, location)
picYaxis.DrawMode = oldDrawMode
picYaxis.DrawWidth = oldDrawWidth
End If
End Sub
Sub Form_Load ()
'Initialize Ruler Locations
picYaxis.Width = 455
picXaxis.Height = 255
picDraw.Width = frmScaleMode.Width - picYaxis.Width
picDraw.Height = frmScaleMode.Height - picXaxis.Height
'Initialize Ruler scale values
picXaxis.ScaleMode = 0 'User-defined
picXaxis.ScaleWidth = 1000
picXaxis.ScaleHeight = 100
picYaxis.ScaleMode = 0 'User-defined
picYaxis.ScaleWidth = 100
picYaxis.ScaleHeight = 1000
'Initialize Ruler fonts
picXaxis.FontName = "Arial"
picXaxis.FontSize = 6
picYaxis.FontName = "Arial"
picYaxis.FontSize = 6
oldCursorX = 0